﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NumberMark
{
    class WinNumber
    {
        //期次
        public int _IssueName;

        public int IssueName
        {
            get { return this._IssueName; }
            set { this._IssueName = value; }
        }

        public Number _Num_01 = new Number();
        public Number Num_01
        {
            get { return this._Num_01; }
            set { this._Num_01 = value; }
        }

        public Number _Num_02 = new Number();
        public Number Num_02
        {
            get { return this._Num_02; }
            set { this._Num_02 = value; }
        }

        public Number _Num_03 = new Number();
        public Number Num_03
        {
            get { return this._Num_03; }
            set { this._Num_03 = value; }
        }

        public Number _Num_04 = new Number();
        public Number Num_04
        {
            get { return this._Num_04; }
            set { this._Num_04 = value; }
        }

        public Number _Num_05 = new Number();
        public Number Num_05
        {
            get { return this._Num_05; }
            set { this._Num_05 = value; }
        }

        public Number _Num_06 = new Number();
        public Number Num_06
        {
            get { return this._Num_06; }
            set { this._Num_06 = value; }
        }

        public Number _Num_07 = new Number();
        public Number Num_07
        {
            get { return this._Num_07; }
            set { this._Num_07 = value; }
        }

        public Number _Num_08 = new Number();
        public Number Num_08
        {
            get { return this._Num_08; }
            set { this._Num_08 = value; }
        }

        public Number _Num_09 = new Number();
        public Number Num_09
        {
            get { return this._Num_09; }
            set { this._Num_09 = value; }
        }

        public Number _Num_10 = new Number();
        public Number Num_10
        {
            get { return this._Num_10; }
            set { this._Num_10 = value; }
        }

        public Number _Num_11 = new Number();
        public Number Num_11
        {
            get { return this._Num_11; }
            set { this._Num_11 = value; }
        }

        public Number _Num_12 = new Number();
        public Number Num_12
        {
            get { return this._Num_12; }
            set { this._Num_12 = value; }
        }

        public WinNumber(String str)
        {
            while(str.Contains("  ")){
                str = str.Replace("  ", " ");
            }
            while (str.Contains("\t"))
            {
                str = str.Replace("\t", " ");
            }
            String[] wnArr = str.Split(' ');
            if (6 != wnArr.Length)
            {
                throw new Exception("输入的号码格式有误：" + str);
            }

            //设置期次名称
            this._IssueName = Int32.Parse(wnArr[0]);

            //设置开奖号码
            #region 设置开奖号码
            for (int i = 1; i < wnArr.Length; i++)
            {
                switch (Int32.Parse(wnArr[i]))
                {
                    case 1:
                        this._Num_01._IsWin = true;
                        this._Num_01._MissCount = 0;
                        this._Num_01._Val = 1;
                        break;
                    case 2:
                        this._Num_02._IsWin = true;
                        this._Num_02._MissCount = 0;
                        this._Num_02._Val = 2;
                        break;
                    case 3:
                        this._Num_03._IsWin = true;
                        this._Num_03._MissCount = 0;
                        this._Num_03._Val = 3;
                        break;
                    case 4:
                        this._Num_04._IsWin = true;
                        this._Num_04._MissCount = 0;
                        this._Num_04._Val = 4;
                        break;
                    case 5:
                        this._Num_05._IsWin = true;
                        this._Num_05._MissCount = 0;
                        this._Num_05._Val = 5;
                        break;
                    case 6:
                        this._Num_06._IsWin = true;
                        this._Num_06._MissCount = 0;
                        this._Num_06._Val = 6;
                        break;
                    case 7:
                        this._Num_07._IsWin = true;
                        this._Num_07._MissCount = 0;
                        this._Num_07._Val = 7;
                        break;
                    case 8:
                        this._Num_08._IsWin = true;
                        this._Num_08._MissCount = 0;
                        this._Num_08._Val = 8;
                        break;
                    case 9:
                        this._Num_09._IsWin = true;
                        this._Num_09._MissCount = 0;
                        this._Num_09._Val = 9;
                        break;
                    case 10:
                        this._Num_10._IsWin = true;
                        this._Num_10._MissCount = 0;
                        this._Num_10._Val = 10;
                        break;
                    case 11:
                        this._Num_11._IsWin = true;
                        this._Num_11._MissCount = 0;
                        this._Num_11._Val = 11;
                        break;
                    case 12:
                        this._Num_12._IsWin = true;
                        this._Num_12._MissCount = 0;
                        this._Num_12._Val = 12;
                        break;
                    default:
                        break;
                }
            }
            #endregion

        }

        public void setMissCounts(WinNumber lastWinNum)
        {
            if ((!this._Num_01._IsWin) && (!lastWinNum._Num_01._IsWin))
            {
                this._Num_01._MissCount = lastWinNum._Num_01._MissCount + 1;
            }
            if ((!this._Num_02._IsWin) && (!lastWinNum._Num_02._IsWin))
            {
                this._Num_02._MissCount = lastWinNum._Num_02._MissCount + 1;
            }
            if ((!this._Num_03._IsWin) && (!lastWinNum._Num_03._IsWin))
            {
                this._Num_03._MissCount = lastWinNum._Num_03._MissCount + 1;
            }
            if ((!this._Num_04._IsWin) && (!lastWinNum._Num_04._IsWin))
            {
                this._Num_04._MissCount = lastWinNum._Num_04._MissCount + 1;
            }
            if ((!this._Num_05._IsWin) && (!lastWinNum._Num_05._IsWin))
            {
                this._Num_05._MissCount = lastWinNum._Num_05._MissCount + 1;
            }
            if ((!this._Num_06._IsWin) && (!lastWinNum._Num_06._IsWin))
            {
                this._Num_06._MissCount = lastWinNum._Num_06._MissCount + 1;
            }
            if ((!this._Num_07._IsWin) && (!lastWinNum._Num_07._IsWin))
            {
                this._Num_07._MissCount = lastWinNum._Num_07._MissCount + 1;
            }
            if ((!this._Num_08._IsWin) && (!lastWinNum._Num_08._IsWin))
            {
                this._Num_08._MissCount = lastWinNum._Num_08._MissCount + 1;
            }
            if ((!this._Num_09._IsWin) && (!lastWinNum._Num_09._IsWin))
            {
                this._Num_09._MissCount = lastWinNum._Num_09._MissCount + 1;
            }
            if ((!this._Num_10._IsWin) && (!lastWinNum._Num_10._IsWin))
            {
                this._Num_10._MissCount = lastWinNum._Num_10._MissCount + 1;
            }
            if ((!this._Num_11._IsWin) && (!lastWinNum._Num_11._IsWin))
            {
                this._Num_11._MissCount = lastWinNum._Num_11._MissCount + 1;
            }
            if ((!this._Num_12._IsWin) && (!lastWinNum._Num_12._IsWin))
            {
                this._Num_12._MissCount = lastWinNum._Num_12._MissCount + 1;
            }
        }
    }
}
